/**
 * @author liangxi
 * @since 2023/12/21
 */

#ifndef DESIGNPATTERN_CAFFEINEBEVERAGEWITHHOOK_H
#define DESIGNPATTERN_CAFFEINEBEVERAGEWITHHOOK_H


#include <iostream>

namespace TemplateMethod_B {

    class CaffeineBeverageWithHook {
    public:

        void prepareRecipe() {
            boilWater();
            brew();
            pourInCup();
            if (customerWantsCondiments()) {
                addCondiments();
            }
        }

        virtual ~CaffeineBeverageWithHook() = default;

        virtual void brew() = 0;

        virtual void addCondiments() = 0;

        void boilWater() {
            std::cout << "Boiling water" << std::endl;
        }

        void pourInCup() {
            std::cout << "Pouring into cup" << std::endl;
        }

        virtual bool customerWantsCondiments() {
            return true;
        }
    };

} // TemplateMethod_B

#endif //DESIGNPATTERN_CAFFEINEBEVERAGEWITHHOOK_H
